﻿using System;
using System.Collections.Generic;
using System.Linq;
using battlenet.wow.rt.domain.objects;
using battlenet.wow.rt.sdk.data.dto;
using battlenet.wow.rt.sdk.utility;
using BnFile = battlenet.wow.rt.domain.objects.BnFile;

namespace battlenet.wow.rt.sdk.objects.mapper
{
    internal class AuctionHouseFileCollectionMapper : Remapper<AuctionHouseFileCollection>
    {
        public override void RegisterMappers()
        {
            Register(typeof(IEnumerable<BnFileInfo>), input => Map(input as IEnumerable<BnFileInfo>));
            Register(typeof(IEnumerable<BnFile>), input => Map(input as IEnumerable<BnFile>));
            Register(typeof(AuctionStatusInfo), input => Map(input as AuctionStatusInfo));
        }

        internal AuctionHouseFileCollection Map(IEnumerable<BnFileInfo> infos)
        {
            var bnFiles = infos.Select(i => i.Remap(new BnFileMapper()));
            return new AuctionHouseFileCollection(bnFiles);
        }

        internal AuctionHouseFileCollection Map(IEnumerable<BnFile> files)
        {
            return new AuctionHouseFileCollection(files);
        }

        internal AuctionHouseFileCollection Map(AuctionStatusInfo info)
        {
            var infos = info.Files.Select(f => f.Remap(new BnFileMapper()));
            return new AuctionHouseFileCollection(infos);
        }
    }
}